package webmarket;

import model.Customer;
import model.Store;

/**
 * @author Simos
 */

public class UserSetMarket extends javax.swing.JFrame {

    /**
     * Creates new form UserSetMarket
     */
    Customer logedUser;
    Store    selectedStore;

    public UserSetMarket() {
        initComponents();
    }
    public void setLogedUser (Customer logedUser) {
        this.logedUser     = logedUser;
    }
    public void setStore (Store selectedStore) {
        this.selectedStore = selectedStore;
        this.selectedStoreText1.setText(selectedStore.getName());
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {

                ExitButton = new javax.swing.JButton();
                list1 = new java.awt.List();
                jLabel1 = new javax.swing.JLabel();
                UserQuantitySelectButton = new javax.swing.JButton();
                UserBasketButton = new javax.swing.JButton();
                selectedStoreText1 = new javax.swing.JTextField();
                jLabel2 = new javax.swing.JLabel();

                setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                setTitle("WebMarket - Αγορά προϊόντων");

                ExitButton.setText("Πίσω");
                ExitButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                ExitButtonActionPerformed(evt);
                        }
                });

                jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
                jLabel1.setText("Επιλέξτε προϊόντα");

                UserQuantitySelectButton.setText("Προσθήκη στο καλάθι");
                UserQuantitySelectButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                UserQuantitySelectButtonActionPerformed(evt);
                        }
                });

                UserBasketButton.setText("Μετάβαση στο καλάθι");
                UserBasketButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                UserBasketButtonActionPerformed(evt);
                        }
                });

                selectedStoreText1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                selectedStoreText1.setEnabled(false);
                selectedStoreText1.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                selectedStoreText1ActionPerformed(evt);
                        }
                });

                jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
                jLabel2.setText("Επιλεγμένο Κατάστημα");

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addGap(81, 81, 81)
                                .addComponent(UserQuantitySelectButton)
                                .addGap(141, 141, 141)
                                .addComponent(UserBasketButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 206, Short.MAX_VALUE)
                                .addComponent(ExitButton)
                                .addGap(80, 80, 80))
                        .addComponent(list1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createSequentialGroup()
                                .addGap(336, 336, 336)
                                .addComponent(jLabel1)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(selectedStoreText1, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(207, 207, 207))
                );
                layout.setVerticalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(selectedStoreText1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel2))
                                .addGap(25, 25, 25)
                                .addComponent(list1, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(33, 33, 33)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(ExitButton)
                                        .addComponent(UserQuantitySelectButton)
                                        .addComponent(UserBasketButton))
                                .addGap(33, 33, 33))
                );

                pack();
        }// </editor-fold>//GEN-END:initComponents

    private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitButtonActionPerformed
        UserMarket usermarket = new UserMarket();
        usermarket.setLogedUser(logedUser);
        usermarket.setLocationRelativeTo(null);
        usermarket.setVisible(true);
        dispose();
    }//GEN-LAST:event_ExitButtonActionPerformed

    private void UserQuantitySelectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UserQuantitySelectButtonActionPerformed
        UserQuantitySelect userquantityselect = new UserQuantitySelect();
        userquantityselect.setLogedUser(logedUser);
        userquantityselect.setLocationRelativeTo(null);
        userquantityselect.setVisible(true);
        dispose();
    }//GEN-LAST:event_UserQuantitySelectButtonActionPerformed

    private void UserBasketButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UserBasketButtonActionPerformed
        UserBasket userbasket = new UserBasket();
        userbasket.setLogedUser(logedUser);
        userbasket.setLocationRelativeTo(null);
        userbasket.setVisible(true);
        dispose();
    }//GEN-LAST:event_UserBasketButtonActionPerformed

        private void selectedStoreText1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedStoreText1ActionPerformed
                // TODO add your handling code here:
        }//GEN-LAST:event_selectedStoreText1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UserSetMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UserSetMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UserSetMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UserSetMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new UserSetMarket().setVisible(true);
            }
        });
    }

        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton ExitButton;
        private javax.swing.JButton UserBasketButton;
        private javax.swing.JButton UserQuantitySelectButton;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private java.awt.List list1;
        private javax.swing.JTextField selectedStoreText1;
        // End of variables declaration//GEN-END:variables
}
